|
|
 |
|
|
|
|
oRS.Close
' Now Use the Command object again With oRS
.CursorType = adOpenKeyset
.LockType = adLockPessimistic
End With
With oCmd Set .ActiveConnection = goConn
Set oRS = .Execute
End With
lstNames.Clear
Do Until oRS.EOF
lstNames.AddItem oRS("szLast_nm") & _
", " & oRS("sFirst_nm")
oRS.MoveNext
Loop
oRS.Close
Set oCmd = Nothing
Set oRS = Nothing
End Sub |
|
|
|
|
|
|
|
|
In this code, you create a Recordset object and a Command object. First, you set up the cursor types and lock types for the Recordset object. Next, you create the Command object and fill in the CommandText property with the SQL statement. You should set the CommandType to tell it that this is a SQL statement in the CommandText property. This helps with optimizationthe Command object does not have to figure out whats in the CommandText property. You next set the ActiveConnection property to either a connect string or a Connection object. Once youve set all these parameters, you just need to perform the Execute method on the Command object to have it return a recordset. |
|
|
|
|
|
|
|
|
ActiveX Data Objects (ADO) is a very easy object model to learn because it doesnt have that many objects. With just a Recordset object, a SQL string, and a connection string, you can start accessing data. You can create a global Connection |
|
|
|
|
|